<template>
    <div class="demo-page">

      <van-nav-bar
        title="demo--练习页"
        left-arrow
        @click-left="$router.push('/publish')"
      />

      <!-- 引入公共组件, 一般组件之间互不影响, 但是有个别组件，例如： 树形组件   -->
      <!--<com-input :parentValue="desc1" @getChangeValue="handleChangeOne"></com-input>-->


      <com-full-address
        :frontLabel="'企业'"
        :showFullAddressObj="showFullAddressObj"
        @getFullAddressValue="toGetFullAddress_company"
        @updateRegionFourName="toUpdateRegionFourName"
        @updateDetailAddress="toUpdateDetailAddress"
        :disabled="false"
        :isUpdate="true"
      ></com-full-address>



    </div>
</template>

<script>
  import comInput from '../../components/comInput';
  import comFullAddress from '../../components/comFullAddress';
  import comSearchByDate from '../../components/comSearchByDate';
  import comPagination from '../../components/comPagination';
  import comTopNavBar from "../../components/comTopNavBar";




  export default {
    name: 'demo',
    components:{
      comInput,
      comFullAddress,
      comSearchByDate,
      comPagination,
      comTopNavBar,
    },
    data() {
      return {
        pageSizeCount: 6,
        total: 30,
        showFullAddressObj: {
          region_four_name: "",
          detail_address: "",
        },

        /*showFullAddressObj: {
          region_four_name: "",
          detail_address: ""
        },*/

        desc1: 'LY马到成功',
        desc2: 'YJH心想事成',


        // 设计一个上传图片的动态的v-mode
        uploadImgList:[
          {
            label:'身份证正面',
            id:'1',
            modeCode:[]
          },
          {
            label:'身份证反面',
            id:'2',
            modeCode:[]
          },
          {
            label:'近期照片',
            id:'3',
            modeCode:[]
          },
        ],

        regions: {
        },

      };
    },

    methods: {

      // 封装组件，得到由子组件传递来的数据
      // toGetFullAddress_*** 由于标识某个页面的地址：如企业认证页、发布页、demo页
      // 参数keyWord 用于标识某个页面中有多个，若只需要一个，则参数keyWord就是noKey
      toGetFullAddress_company(regions, keyWord){
        console.log('子组件传递过来的', regions)
        this.regions = regions
      },

      // 修改四级地址（清空详细地址）
      toUpdateRegionFourName(newObj){
        this.showFullAddressObj.region_four_name = newObj.region_four_name
        this.showFullAddressObj.detail_address = ''
      },

      // 修改详细地址
      toUpdateDetailAddress(newValue){
        this.showFullAddressObj.detail_address = newValue
      },

      onSubmit(values){
        const {uploaderPhoto} = values
        console.log('根据name搜集输入的值（若有v-for只取最后一个）', uploaderPhoto)
      },

      handleChangeOne(data){
        console.log('子组件到父组件的数据', data)
        this.desc1 = data
      },


      toGetCalendarValue(val){
        console.log('子组件到父组件的数据', val)
      },


    },

  }
</script>

<style scoped lang="scss">
  .demo-page{
    width: 100%;
    /* 样式的透传 */
    /deep/ .van-dropdown-item__option--active{
      color: blue;
      font-weight: bold;
    }
    .icon{
      position: absolute;
      top: 10px;
      left: 80px;
      width: 0;
      height: 0;
      border: 10px solid transparent;
      border-top-color: #cccccc;
    }
  }
</style>
